const express = require('express');
const router = express.Router();
const db = require('../../../../util/dbConfig/dbConfig')

//加载正在使用该系统的用户的个人信息
router.post('/',(req,res) => {
    let id = req.session.userInfo._id
    if(!id){
        return res.send({
            code: 1,
            msg: '请先登录'
        })
    }
    //有id
    try{
        let sql = `select ID,NAME,PHONENUM,PASSWORD,CREATE_DATE from user where ISDELETE=0 and ID=?`
        let sqlArr = [id]
        let callBack = (err,data) => {
            if(err){
                console.log(err);
            }else{
                return res.send({
                    code: 0,
                    msg: '加载成功',
                    data
                })
            }
        }
        db.sqlConnect(sql,sqlArr,callBack)
    }catch (e) {
        console.log(e);
        return res.send({
            code: 4,
            msg: '服务器错误，请稍后再试'
        })
    }
})

module.exports = router
